package graphics.operations;

import graphics.Triangolo;

import java.awt.Graphics;
import java.awt.event.MouseEvent;

public class AddTriangoloOperation extends Operation{

	private int state=0;
	Triangolo triangolo;
	
	
	public void mousePressed(MouseEvent arg0) {
		
		
		
		switch(state){
			case 0:
				triangolo=new Triangolo();
				triangolo.setX1(arg0.getX());
				triangolo.setY1(arg0.getY());
				getData().addForma(triangolo);
			case 1:
				triangolo.setX2(arg0.getX());
				triangolo.setY2(arg0.getY());
			case 2:
				triangolo.setX3(arg0.getX());
				triangolo.setY3(arg0.getY());
		}
		getData().aggiorna();
		
		state++;
		if(state==3)
			state=0;
	}
	
	
	public void mouseClicked(MouseEvent arg0) {
		//Do nothing
	}
	
	
	public void mouseDragged(MouseEvent arg0) {
		//Do nothing
	}
	
	
	public void mouseEntered(MouseEvent arg0) {
		//Do nothing
	}
	
	
	public void mouseExited(MouseEvent arg0) {
		
	}
	
	
	public void mouseMoved(MouseEvent arg0) {
		switch(state){
			case 1:
				triangolo.setX2(arg0.getX());
				triangolo.setY2(arg0.getY());
				break;
			case 2:
				triangolo.setX3(arg0.getX());
				triangolo.setY3(arg0.getY());
				break;
		}
		getData().aggiorna();
	}
	
	
	public void mouseReleased(MouseEvent arg0) {
		//Do nothing
	}
	
	
	public void drawOperationInfo(Graphics graphics) {
		//Do nothing
	}
}
